<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function makeCounter() {
        let count = 1;
        const fn = function () {
          return ++count;
        }; // fn = {};
        fn.set = function (value) {
          count = value;
          return count;
        };
        fn.decrease = function () {
          return --count;
        };
        return fn;
      }
      const counter = makeCounter();
      console.log(counter.set(100)); //100
      console.log(counter()); //101
      console.log(counter.decrease()); //100
    </script>
  </body>
</html>
